from __future__ import annotations

from dataclasses import dataclass


@dataclass
class SteelMemberCheck:
    stress_MPa: float
    utilization: float
    ok: bool
    note: str


def check_steel_member(
    axial_kN: float = 0.0,
    moment_kNm: float = 0.0,
    section_area_mm2: float = 1000.0,
    section_modulus_mm3: float = 1.0e6,
    design_strength_MPa: float = 215.0,
) -> SteelMemberCheck:
    """钢构件轴力+弯矩的正应力强度校核。"""

    sigma_N = (axial_kN * 1e3) / max(1.0, section_area_mm2)
    sigma_M = (moment_kNm * 1e6) / max(1.0, section_modulus_mm3)
    sigma = abs(sigma_N) + abs(sigma_M)
    u = sigma / max(1e-6, design_strength_MPa)
    return SteelMemberCheck(stress_MPa=sigma, utilization=u, ok=u <= 1.0, note="σ/ƒ设计 ≤ 1.0")


